<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>统计</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script src="libs/layer/layer.js"></script>
  <link href="libs/Font-Awesome/css/font-awesome.min.css" rel="stylesheet">
  <script src="libs/handlebars.min.js"></script>
  <script src="libs/d3.v3.min.js" charset="utf-8"></script>
  <link href="libs/nv.d3.min.css" rel="stylesheet">
  <script src="libs/nv.d3.min.js"></script>
  <script src="libs/js.cookie-2.1.0.min.js"></script>
  <script  type="text/javascript" src="libs/handlebars.min.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
      <div class="page-header">
      <h1 align="center"><strong>llq记账统计</strong></h1>
      </div>
    </div>
  </div>
  <div class="container">
  <div class="row">
    <div class="col-md-8">
      <ul class="nav nav-pills">
        <li >
        <a href="index.html"><strong>首页</strong></a>
        </li>
          <li>
        <a href="moneyout.html"><strong>新加支出</strong></a>
        </li>
        <li>
        <a href="moneyin.html"><strong>新加收入</strong></a>
        </li>
         <li>
        <a href="query.html"><strong>查询</strong></a>
        </li>
        <li class="active" >
        <a href="statis.html"><strong>统计</strong></a>
        </li>
      </ul>
    </div>
  </div>
</div>
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <hr/>
    </div>
  </div>
</div>
<div class="container">
<h1>
    <div class="row">
      <div class="col-md-6">
        <div class="panel panel-primary">
          <div class="panel-heading"><strong>当月收入总和</strong></div>
          <div class="panel-body" id="text1"></div>
        </div>
      </div>
         <div class="col-md-6">
        <div class="panel panel-primary">
          <div class="panel-heading"><strong>当月支出总和</strong></div>
          <div class="panel-body" id="text2"></div>
        </div>
      </div>
    </div>
</h1>
 <div class="row">
      <div class="col-md-12">
        <div class="panel panel-warning">
          <div class="panel-heading"><h4><strong>每个类别收入总和、平均</strong></h4></div>
          <div class="panel-body" id="list1"></div>
        </div>
      </div>
   
   
</div>
     <div class="row">
      <div class="col-md-12">
        <div class="panel panel-warning">
          <div class="panel-heading"><h4><strong>每个类别支出总和、平均</strong></h4></div>
          <div class="panel-body" id="list2"></div>
        </div>
      </div>
    </div>
    </div>
<div class="container">
  <div class="row">
    <div class="col-md-6" id="chart">
      <p class="text-center" >
      <br/>
      <hr/>
      <strong>收入统计</strong>
      <svg style="height:480px;width:100%"></svg>
      <br>
      </p>
    

</div>

    <div class="col-md-6" id="chart1">
      <p class="text-center" >
      <br/>
      <hr/>
      <strong>支出统计</strong>
      <svg style="height:480px;width:100%"></svg>
      <br>
      </p> 
</div>
  </div>
</div>

  <script type="text/x-handlebars-template" id="template">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
  <dl>
  <dt>类别</dt><dd>{{kind}}</dd>
  <dt>总和</dt><dd>{{si}}</dd>
  <dt>平均</dt><dd>{{avmi}}</dd>
  </dl>
  </div>
</div>
{{/each}}
</script>
<script type="text/x-handlebars-template" id="template1">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
  <dl>
  <dt>类别</dt><dd>{{kind}}</dd>
  <dt>总和</dt><dd>{{so}}</dd>
  <dt>平均</dt><dd>{{avmo}}</dd>
  </dl>
  </div>
</div>
{{/each}}
</script>
  <script type="text/javascript">
  $(function () {
	  $.getJSON('querymonth.action', function(res){
	       
	       $('#text1').text(res.smi); 
	       $('#text2').text(res.smo);
	  });
     
      $.getJSON('query_money_kindin.action', function(res){ 
	       var data ={'item':res};
 	       var t=Handlebars.compile($('#template').html());
 	       $('#list1').html(t(data));
 });
      $.getJSON('query_money_kindout.action', function(res){ 
	       var data ={'item':res};
	       var t=Handlebars.compile($('#template1').html());
	       $('#list2').html(t(data));
	      
}); $.getJSON('query_money_kindin.action', function(res){
	nv.addGraph(function(){
		var chart =nv.models.pieChart()
		.x(function(d){
			return d.kind
		}).y(function(d){
			return d.si
		}).showLabels(true)
		.labelType('percent');
		d3.select("#chart svg")
		.datum(res)
		.transition().duration(350)
		.call(chart);
		return chart;
	}) 
  })
   $.getJSON('query_money_kindout.action', function(res){
	nv.addGraph(function(){
		var chart1 =nv.models.pieChart()
		.x(function(d){
			return d.kind
		}).y(function(d){
			return d.so
		}).showLabels(true)
		.labelType('percent');
		d3.select("#chart1 svg")
		.datum(res)
		.transition().duration(350)
		.call(chart1);
		return chart1;
	}) 
  })
})

  
  
  </script>
</body>

</html>